using System.Collections.Generic;
using BruteForce.UserInterface.Interfaces;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace BruteForce.UserInterface.Abstracts
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public abstract class AbstractPanel
    {
        protected readonly List<AbstractUIControl> _uiControls;
        public Rectangle Bounds;
        protected string PanelName;

        protected AbstractPanel(string panelName)
        {
            PanelName = panelName;
            _uiControls = new List<AbstractUIControl>();
        }

        public List<AbstractUIControl> Children
        {
            get { return _uiControls; }
        }

        public IScreen Parent { get; set; }

        public void AddUIControl(AbstractUIControl uiControl)
        {
            _uiControls.Add(uiControl);
        }

        public bool RemoveUIControl(AbstractUIControl uiControl)
        {
            return _uiControls.Remove(uiControl);
        }

        public abstract void AfterLayout();

        //calculate the centered rectangle inside a rectangle 
        public Rectangle CalculteCenteredRectangle(Rectangle panelRectangle, int width, int hight)
        {
            int midX = panelRectangle.X + panelRectangle.Width/2 - width/2;
            int midY = panelRectangle.Y + panelRectangle.Height/2 - hight/2;
            return new Rectangle(midX, midY, width, hight);
        }


        public abstract void Update(GameTime gameTime);

        public abstract void Draw(GameTime gameTime, SpriteBatch spriteBatch);

        //public abstract void LoadContent(ContentManager content);
    }

    public enum PanelLocation
    {
        Bottom,
        Top,
        Left,
        Right,
        Center
    }
}